package bocchi.card;

import bocchi.BocchiCore;
import bocchi.base.BaseCustomCard;
import bocchi.general.Util;
import bocchi.power.ErosionPower;
import com.evacipated.cardcrawl.mod.stslib.actions.common.AllEnemyApplyPowerAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class DoubleDarkPasts extends BaseCustomCard {
    private static final String RAW_ID = DoubleDarkPasts.class.getSimpleName();
    public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public DoubleDarkPasts() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        Util.damage(player, monster, damage);
        int count = 0;
        for (AbstractCard card : player.hand.group) {
            if (card.cardID.equals(DarkPast.GAME_ID)) {
                count++;
            }
        }

        for (AbstractCard card : player.drawPile.group) {
            if (card.cardID.equals(DarkPast.GAME_ID)) {
                count++;
            }
        }

        for (AbstractCard card : player.discardPile.group) {
            if (card.cardID.equals(DarkPast.GAME_ID)) {
                count++;
            }
        }

        if (count >= 2) {
            addToBot(new AllEnemyApplyPowerAction(player, magicNumber, m -> new ErosionPower(m, magicNumber)));
        }
    }
}
